//
//  QNHeader.h
//  QNDividingRuler
//
//  Created by rsh on 2019/12/7.
//  Copyright © 2019年 rsh. All rights reserved.
//

#ifndef QNHeader_h
#define QNHeader_h

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
#import "UIColor+QNHexColor.h"
#import <Masonry/Masonry.h>
#import <SDWebImage/SDWebImage.h>


/**
 * 档位状态view的高度为158，其他状态为140；
 * 刷新view时，记得要重新设置档位状态下的的高为158；
 **/


//===============================================================

typedef NS_ENUM(NSUInteger, DividingRulerStyle) {
    DividingRulerStyle_Default,      ///占位状态
    DividingRulerStyle_Temperature,  ///温度
    DividingRulerStyle_Time,         ///时间
    DividingRulerStyle_Gear,         ///档位
    DividingRulerStyle_Weight        ///重量
};


typedef NS_ENUM(NSInteger,QNRulerAlignmentType) {
    QNRulerTypeAlignmentCenter = 0,    ///中间
    QNRulerTypeAlignmentBottom         ///底部
};



//==============================================================


// MARK: 文字、中间浮标主色
#define QNMaiColor             @"#FF5500"
// MARK: 刻度颜色
#define QNKDColor              @"#CDCDCD"
// MARK: 刻度显示文本颜色
#define QNTextColor            @"#9B9B9B"



// MARK: 中间浮标的字体名称
#define CurrentLableFontName   @"DINAlternate-Bold"
// MARK: 刻度文本默认的字体名称
#define ScaleDisLableFontName  @"PingFangSC-Regular"
// MARK: 刻度文本选中的字体名称
#define ScaleSelLableFontName  @"PingFangSC-Medium"



// MARK: 温度符号
#define TemSymbol              @"℃"



//==============================================================


/*
 
 用法介绍：
 
 - (void)viewDidLoad {
 [super viewDidLoad];
 
 [self.view setBackgroundColor:[UIColor whiteColor]];
 ///温度状态
 [self setupTemRuler];
 ///时间状态
 [self setupTimeRuler];
 ///重量状态
 [self setupWeightRuler];
 ///档位状态
 [self setupGearRule];
 }
 
 
 ///温度状态
 -(void)setupTemRuler{
 
 // 变速区域
 QNDividingRulerView * rulerView = [[QNDividingRulerView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 140)];
 //最大值260℃
 rulerView.maxValue = 260;
 //最小值150℃
 rulerView.minValue = 150;
 //单元值5℃
 rulerView.unitValue = 5;
 //默认值210℃
 rulerView.defaultValue = 210;
 //刻度文案之间的刻度格数
 rulerView.scalesCountBetweenScaleText = 4;
 //刻度之间的步径
 rulerView.scalesCountBetweenLargeLine = 4;
 // 设置显示状态--温度状态
 rulerView.rulerStyle = DividingRulerStyle_Temperature;
 //要显示刻度尺上的文案必须要调用（文案有单位，需带上单位）
 [rulerView setScaleTextFormatBlock:^NSString *(CGFloat currentValue, NSInteger scaleIndex) {
 return [NSString stringWithFormat:@"%.0f",currentValue];
 }];
 //结束滚动(中间刻度值，有单位带上单位)
 [rulerView setDividingRulerDidEndScrollingBlock:^NSString *(CGFloat value) {
 //**********我们要最终获取的值:value *************
 return [NSString stringWithFormat:@"%.f℃",value];
 }];
 //滚动中(中间刻度值，有单位带上单位)
 [rulerView setDividingRulerDidScrollBlock:^NSString *(CGFloat value,CGPoint rulerContentOffset) {
 return [NSString stringWithFormat:@"%.f℃",value];
 }];
 [rulerView setFrame:CGRectMake(0, 30, CGRectGetWidth(self.view.frame), 140)];
 [rulerView updateRuler];
 [self.view addSubview:rulerView];
 }
 
 
 /// 时间状态（传入值为分钟）
 -(void)setupTimeRuler{
 
 // 变速区域
 QNDividingRulerView * rulerView = [[QNDividingRulerView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 140)];
 //最大值300分钟
 rulerView.maxValue = 300;
 //最小值30分钟
 rulerView.minValue = 30;
 //单元值1分钟
 rulerView.unitValue = 1;
 //默认值85分钟
 rulerView.defaultValue = 85;
 //刻度文案之间的刻度格数
 rulerView.scalesCountBetweenScaleText = 5;
 //刻度之间的步径
 rulerView.scalesCountBetweenLargeLine = 5;
 // 设置显示状态--时间状态
 rulerView.rulerStyle = DividingRulerStyle_Time;
 //要显示刻度尺上的文案必须要调用（文案有单位，需带上单位）
 [rulerView setScaleTextFormatBlock:^NSString *(CGFloat currentValue, NSInteger scaleIndex) {
 NSInteger totalSeconds = currentValue * 60;
 NSInteger hours = totalSeconds / 3600;
 NSInteger minutes = (totalSeconds/60) % 60;
 NSUInteger seconds = totalSeconds % 60;
 if (hours > 0) {
 return [NSString stringWithFormat:@"%ld:%02ld",(long)hours,(long)minutes];
 }else{
 return [NSString stringWithFormat:@"%ld:%02lu",(long)minutes,(unsigned long)seconds];
 }
 }];
 //结束滚动(中间刻度值，有单位带上单位)
 [rulerView setDividingRulerDidEndScrollingBlock:^NSString *(CGFloat value) {
 //**********我们要最终获取的值:value *************
 return [NSString stringWithFormat:@"%.f",value];
 }];
 //滚动中(中间刻度值，有单位带上单位)
 [rulerView setDividingRulerDidScrollBlock:^NSString *(CGFloat value,CGPoint rulerContentOffset) {
 return [NSString stringWithFormat:@"%.f",value];
 }];
 [rulerView setFrame:CGRectMake(0, 200, CGRectGetWidth(self.view.frame), 140)];
 [rulerView updateRuler];
 [self.view addSubview:rulerView];
 }
 
 
 ///重量状态（g或kg单位都可传，文档有单位记得带上单位）
 -(void)setupWeightRuler{
 
 // 变速区域
 QNDividingRulerView * rulerView = [[QNDividingRulerView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 140)];
 //最大值300g
 rulerView.maxValue = 300;
 //最小值10g
 rulerView.minValue = 10;
 //单元值2g
 rulerView.unitValue = 2;
 //默认值150g
 rulerView.defaultValue = 150;
 //刻度文案之间的刻度格数
 rulerView.scalesCountBetweenScaleText = 5;
 //刻度之间的步径
 rulerView.scalesCountBetweenLargeLine = 5;
 //设置显示状态--重量状态
 rulerView.rulerStyle = DividingRulerStyle_Weight;
 //要显示刻度尺上的文案必须要调用（文案有单位，需带上单位）
 [rulerView setScaleTextFormatBlock:^NSString *(CGFloat currentValue, NSInteger scaleIndex) {
 return [NSString stringWithFormat:@"%.0fg",currentValue];
 }];
 //结束滚动(中间刻度值，有单位带上单位)
 [rulerView setDividingRulerDidEndScrollingBlock:^NSString *(CGFloat value) {
 //**********我们要最终获取的值:value *************
 return [NSString stringWithFormat:@"%.fg",value];
 }];
 //滚动中(中间刻度值，有单位带上单位)
 [rulerView setDividingRulerDidScrollBlock:^NSString *(CGFloat value,CGPoint rulerContentOffset) {
 return [NSString stringWithFormat:@"%.fg",value];
 }];
 [rulerView setFrame:CGRectMake(0, 370, CGRectGetWidth(self.view.frame), 140)];
 [rulerView updateRuler];
 [self.view addSubview:rulerView];
 }
 
 
 ///档位状态（刻度上面带图片显示）
 -(void)setupGearRule{
 // 变速区域
 QNDividingRulerView * rulerView = [[QNDividingRulerView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 140)];
 //最大值9档
 rulerView.maxValue = 9;
 //最小值1档
 rulerView.minValue = 1;
 //单元值1档
 rulerView.unitValue = 1;
 //默认值5档
 rulerView.defaultValue = 5;
 //横向两刻度之间的间距
 rulerView.lineSpace = 37.0;
 //刻度文案之间的刻度格数
 rulerView.scalesCountBetweenScaleText = 1;
 //刻度之间的步径
 rulerView.scalesCountBetweenLargeLine = 1;
 //设置显示状态--档位状态
 rulerView.rulerStyle = DividingRulerStyle_Gear;
 //要显示图片的数组
 rulerView.imageArray = @[@{@"scaleIndex":@"0",@"image":@"mb_20"},@{@"scaleIndex":@"4",@"image":@"mb_20"},@{@"scaleIndex":@"8",@"image":@"mb_20"}];
 //要显示刻度尺上的文案必须要调用（文案有单位，需带上单位）
 [rulerView setScaleTextFormatBlock:^NSString *(CGFloat currentValue, NSInteger scaleIndex) {
 return [NSString stringWithFormat:@"%.0f",currentValue];
 }];
 //结束滚动(中间刻度值，有单位带上单位)
 [rulerView setDividingRulerDidEndScrollingBlock:^NSString *(CGFloat value) {
 //**********我们要最终获取的值:value *************
 return [NSString stringWithFormat:@"%.f",value];
 }];
 //滚动中(中间刻度值，有单位带上单位)
 [rulerView setDividingRulerDidScrollBlock:^NSString *(CGFloat value,CGPoint rulerContentOffset) {
 return [NSString stringWithFormat:@"%.f",value];
 }];
 [rulerView setFrame:CGRectMake(0, 540, CGRectGetWidth(self.view.frame), 158)];
 [rulerView updateRuler];
 [self.view addSubview:rulerView];
 }

 
 
 */



#endif /* QNHeader_h */
